# -*- coding: utf-8 -*-

import matplotlib.pyplot as plt
import xml.etree.ElementTree as ET

tree= ET.parse("ListAccessTiming.xml")
root=tree.getroot()


for child in root:
    if child.tag=="Axes":
        for node in child:
            if node.tag=="XAxis":
                xmax=node.attrib["max"]
                xmin=node.attrib["min"]
            if node.tag=="YAxis":
                ymax=node.attrib["max"]
                ymin=node.attrib["min"]
    elif child.tag=="Sequence":
        xpoints=list()
        ypoints=list()
        print child.attrib
        color=child.attrib["color"]
        for node in child:
            if node.tag=="DataPoint":
                xpoints.append(node.attrib["x"])
                ypoints.append(node.attrib["y"])
        if color=="red":
            plt.subplot(111)
            plt.plot(map(float,xpoints),map(float,ypoints),"r",linewidth=3)
        else:
            print "detect"
            plt.plot(map(float,xpoints),map(float,ypoints),"b",linewidth=3)

    else:
        print child.tag
        print child.attrib
                
    
                
    




#pyplot 
plt.title(root.attrib["title"])
plt.axis(map(float,[xmin,xmax,ymin,ymax]))

